#!/usr/bin/python
# -*- coding: utf-8 -*-

import Ice
import sys, os

try:
    HOME = os.environ['FIPA']
except KeyError:
    print 'FIPA environment variable is not currently defined.'
    sys.exit(0)

SLICE = os.path.join(HOME, 'slice')
FILE1 = os.path.join(SLICE, 'FIPA.ice')
Ice.loadSlice('--all -I/usr/share/slice', ['-I' + SLICE, FILE1])

import FIPA

class AMI_Model_receiveMessageI (object):

    def ice_response (self):
        pass

    def ice_exception (self, ex):
        print 'MTSI: ' + str(ex)

class MTSI (FIPA.MTS):

    # FIPA.MTS receiveMessage()
    def receiveMessage (self, m, curr = None):
        cb = AMI_Model_receiveMessageI()
        for prx in m.env.to:
            #print 'MTS: message from ' + str(m.env.frm) + ' to ' + str(prx)
            prx.receiveMessage_async(cb, m)
